<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%> 
<script type="text/javascript">
	var tree_parent_id ;
	var store = new Ext.data.JsonStore({
    	root:"data",
    	totalProperty: "total",
		fields: ["id","name", "type", "contact", "phone", "postal","address","area","supperId","post"],
		url: "organization!listByParent.action"
	});
	
	//类型
	var type_store = new Ext.data.JsonStore({
		fields: ["id","text"],
		data:[{id:"H",text:"总行"},{id:"B",text:"分行"},{id:"S",text:"支行"},{id:"O",text:"分理处"}]
	});
	
	var org_panel = {
		id: "org_grid",
		xtype: "grid",
		stripeRows:true,
		region: "center",
		loadMask : true,//在加载数据时遮罩住元素,替换元素Updater的加载提示器，并且在初始化加载之后销毁
		autoExpandColumn:"address",//自动填充
		autoExpandMin : 100,//自动填充最小宽度
		store: store,
		headersDisabled: true,
		columns:[
        	new Ext.grid.RowNumberer({header: "序号", width: 35}),
        	{header: "机构号", dataIndex: "id",	menuDisabled: true},
        	{header: "机构名称", dataIndex: "name",	menuDisabled: true},
        	{header: "机构类型", dataIndex: "type",	menuDisabled: true,
        		renderer:function(input){
        		if(""==input)return input;
         		return type_store.getById(input).data.text;
        	}},
			{header: "联系人", dataIndex: "contact",	menuDisabled: true},
			{header: "电话", dataIndex: "phone",	menuDisabled: true},
			{header: "邮编", dataIndex: "post",	menuDisabled: true},
			{header: "地址", dataIndex: "address",id:"address",menuDisabled: true}
		],
		bbar: new Ext.ux.PagingToolbar({
			id:"org_paging",
        	pageSize: limit,
        	store: store
    	})
	};
	
	var org_pel=new Ext.Panel({
		id:"master_panel",
		border : false, 
		layout: "border",
		items: [{
				id:"org_tree",
				xtype: "billTreePanel",
				dataUrl: "tree!organization.action",
				root: new Ext.tree.AsyncTreeNode({
					id: "root",
					expanded : true		// 自动展开节点
				}),
				listeners: {
					"click": function(node){
						store.baseParams = store.baseParams || {};
						store.baseParams["parentId"] = node.id;
						store.load({params:{start : 0,limit : limit}});
					}
				}
			}, org_panel]
	});
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(org_pel);
	CenterPanel.doLayout();
</script>